<?php
namespace Common\Controller;
use Think\Controller;
/**
 * Appframe项目公共Controller
 */
class AppframeController extends Controller {


    function _initialize() {
    	
        //消除所有的magic_quotes_gpc转义
        //Input::noGPC();
        //跳转时间
        $this->assign("waitSecond", 3);
        //$this->assign("__token__", $this->getToken());
     
        if(APP_DEBUG){
        	//lap_clear_cache();
        }
        
 
        
        $config = F ( 'Config_site' );
        
     
        C ( $config ); // 添加配置

//

        //$this->error("服务器改造升级!");



    }
    


    //获取表单令牌
    protected function getToken() {
        $tokenName = C('TOKEN_NAME');
        // 标识当前页面唯一性
        $tokenKey = md5($_SERVER['REQUEST_URI']);
        $tokenAray = session($tokenName);
        //获取令牌
        $tokenValue = $tokenAray[$tokenKey];
        return $tokenKey . '_' . $tokenValue;
    }





    
 protected function page($total, $size = 20, $number = 0, $config = array()) {
        $Page =page($total, $size, $number, $config);
        $Page->SetPager('default', '<span class="all">共有{recordcount}条信息</span>{first}{prev}{liststart}{list}{listend}{next}{last}');
        return $Page;
    }


    public function verify(){
    	$verify = new \Think\Verify();
    	$imageH=I('get.imageH');
    	if($imageH)   $verify->__set(imageH,$imageH);
    	$imageW=I('get.imageW');
    	if($imageW)   $verify->__set(imageW,$imageW);
    	 
    	$fontSize=I('get.fontSize');
    	if($fontSize)   $verify->__set(fontSize,$fontSize);
    	 
    	$length=I('get.length');
    	if($length)   $verify->__set(length,$length);
    
    
    	$verify->entry(1);
    }

    //空操作
    public function _empty() {
        //$this->error(MODULE_NAME."-".CONTROLLER_NAME."-".ACTION_NAME);
        
        echo MODULE_NAME."-".CONTROLLER_NAME."-".ACTION_NAME;
    }
    
    /**
     * 检查操作频率
     * @param int $duration 距离最后一次操作的时长
     */
    protected function check_last_action($duration){
    	
    	$action=MODULE_NAME."-".CONTROLLER_NAME."-".ACTION_NAME;
    	$time=time();
    	$s=session('last_action');
    	if(!empty($s['action']) && $action==$s['action']){
    		$mduration=$time-$s['time'];
    		if($duration>$mduration){
    			$this->error("您的操作太过频繁，请稍后再试~~~");
    		}else{
    			$s['time']=$time;
    			session("last_action",$s);
    		}
    	}else{
    		$s['action']=$action;
    		$s['time']=$time;
    		session("last_action",$s);
    	}
    }
    

}

?>
